package com.eischet.lookup.web;

import org.springframework.beans.factory.annotation.Required;

import java.util.Collections;
import java.util.List;

/**
 * Defines a category of searchable objects. The categories give structure to
 * searchable objects. This is mainly a device to make the selection structure
 * in the web application user configurable instead of hard-coded like they were
 * in Lookup 1.x.
 */
public class SearchableCategory {
    private String name;
    private String title;
    private String selectionTitle;
    private boolean selectable;
    private List<SearchableType> searchableTypes = Collections.emptyList();

    /**
     * creates a new category bean
     */
    public SearchableCategory() {
        // pass
    }

    /**
     * @param name the category's name
     */
    @Required
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the category's name
     */
    public String getName() {
        return name;
    }

    /**
     * @param title the title
     */
    @Required
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param selectionTitle the selectable title
     */
    @Required
    public void setSelectionTitle(String selectionTitle) {
        this.selectionTitle = selectionTitle;
    }

    /**
     * @return the selectable title
     */
    public String getSelectionTitle() {
        return selectionTitle;
    }

    /**
     * @param selectable true to make the category selectable
     */
    @Required
    public void setSelectable(boolean selectable) {
        this.selectable = selectable;
    }

    /**
     * @return true if the category is selectable
     */
    public boolean isSelectable() {
        return selectable;
    }

    /**
     * @param searchableTypes the list of searchable types in this category
     */
    @Required
    public void setSearchableTypes(List<SearchableType> searchableTypes) {
        this.searchableTypes = Collections.unmodifiableList(searchableTypes);
    }

    /**
     * @return the list of searchable types in this category
     */
    public List<SearchableType> getSearchableTypes() {
        return searchableTypes;
    }

    /**
     * @return a String representation of this object
     */
    @Override
    public String toString() {
        return String.format("SearchableCategory(name='%s', title='%s', selectable=%s", name, title, selectable);
    }
}
